
#ifndef _ENTITY_H
#define _ENTITY_H

#include <iostream>
#include <Box2D\Box2D.h>
#include <angelscript.h>

#include "objects.h"
#include "levels.h"



enum Entity_Type
{
	ET_NONE = 0,
	ET_CREEP,
	ET_TOWER,
	ET_PROJECTILE
};


enum Entity_State
{
	ES_NONE = 0,
	ES_ACTIVE,
	ES_DEAD
};



class Entity :
	public Objects
{
public:
	Entity();
	//copy constructor
	Entity(const Entity&);
	//Set entities equal to each other
	 Entity& operator = ( const Entity& other );
	 virtual ~Entity();

	 //this is used to sort the class in a list
	 bool operator < (const Entity& rhs)
	 {
		return type < rhs.type;
	 }


	 
	 static bool Register_With_ScriptEngine( const std::string &);

	 //Run Script Driver
	 bool RunScriptDriver(asIScriptContext *);

	 
	 //Get Entity Properties
	virtual bool Get_Config(const std::string&);
//collision
	virtual void OnCollision(const Entity *other_body) {}

//Prepare to Spawn
	virtual void PrepareSpawn(const b2Vec2&);
//Draw
	virtual void Render(sf::RenderWindow *);
//Update
	virtual void Update_Logic( asIScriptContext * );
//Destroy
	virtual void Destroy();

	//Mark this object to be destroyed
	void MarkRemoval();

  
	 int damage;
	 //std::string name;
	 int type;


//Script stuff
	 std::string * script_location;
	bool hasDriver;
	int driverFunctionID;

		


//Physics Actor
	b2Body * body;

	b2BodyDef bodyDef;
	b2FixtureDef fixtureDef;

	b2PolygonShape shapeDef;
	b2CircleShape circleDef;

//GC stuff
	 void AddRef();
	 void Release();

protected:

	
	//Copy the entity
	virtual void copyEntity(const Entity *);

	
	bool marked_for_removal;


	int refCount;

};

#endif